package com.springcloud.tread.service;

import cn.hutool.core.collection.CollUtil;
import com.springcloud.tread.pojo.IndexData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Service
@CacheConfig(cacheNames = "index-datas")
public class IndexDataService {

    private List<IndexData> list;


    //从缓存中获取
    @Cacheable(key="'index-data-'+#p0")//先查看缓存中是否有数据,有则直接返回，没有则调用方法，方法返回的是一个空的list,同步到reids缓存
    public  List<IndexData> get(String id)
    {
        IndexData indexData= new IndexData();
        indexData.setDate("无信息！！");
        indexData.setClosePoint(0);
        list.add(indexData);
        return CollUtil.toList(indexData);
    }
}
